#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    string s;
    cin >> s;
    ll n = s.size();
    string ans(n, '0');
    switch (s[0])
    {
    case '1':
        ans[0] = '2';
        break;
    case '2':
        ans[0] = '3';
        break;
    case '3':
        ans[0] = '5';
        break;
    case '4':
        ans[0] = '7';
        break;
    case '5':
        ans[0] = '7';
        break;
    case '6':
        ans[0] = '7';
        break;
    case '7':
        ans[0] = '1';
        ans += '1';
        break;
    case '8':
        ans[0] = '1';
        ans += '1';
        break;
    case '9':
        ans[0] = '1';
        ans += '1';
        break;
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}